#__author__=='qustl_000'
#-*- coding: utf-8 -*-

import kNN
from numpy import *

'''numpy实现KNN'''
traingData,testData=kNN.createDataSet(r"iris.txt",0.7)
trainCharacter,trainLabel=kNN.dataLabel(traingData)
testCharacter,testLabel=kNN.dataLabel(testData)

print(array(traingData))
print(array(testData))

'''分类并计算错误率'''
print("分类结果为： ")
errorCount = 0
for i in range(len(testCharacter)):
    classifyResult=kNN.classify0(testCharacter[i],trainCharacter,trainLabel,3)
    print(classifyResult)
    if(classifyResult !=testLabel[i]):
        errorCount+=1
errorRate=float(errorCount/(len(testCharacter)-1))
print("错误率为：",errorRate)

'''sklearn kNN分类实例'''
#kNN.classifyIris()



